using System;
using System.Data;

namespace ICeFramework.Common.DataLayer
{
    /// <summary>
    /// 
    /// </summary>
    /// <remarks></remarks>
    /// <example></example>
    [Serializable()]
    public class DataParameter : IDataParameter
    {
        #region public DataParameter(string name, object value, DbType dbType)
        /// <summary>
        /// Initializes a new instance of the <b>DataParameter</b> class.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        /// <param name="dbType"></param>
        public DataParameter(string name, object value, DbType dbType)
        {
            _parameterName = name;
            _value = value;
            _dbType = dbType;
        }
        #endregion

        #region public DataParameter(string name, object value)
        /// <summary>
        /// Initializes a new instance of the <b>DataParameter</b> class.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        public DataParameter(string name, object value)
        {
            _parameterName = name;
            _value = value;
        }
        #endregion

        #region public DataParameter(string name, object value, DbType dbType, ParameterDirection direction, DataRowVersion version, string sourceColumn, bool isNullable)
        /// <summary>
        /// Initializes a new instance of the <b>DataParameter</b> class.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        /// <param name="dbType"></param>
        /// <param name="direction"></param>
        /// <param name="version"></param>
        /// <param name="sourceColumn"></param>
        /// <param name="isNullable"></param>
        public DataParameter(string name, object value, DbType dbType, ParameterDirection direction,
                            DataRowVersion version, string sourceColumn, bool isNullable)
        {
            _parameterName = name;
            _value = value;
            _dbType = dbType;
            _direction = direction;
            _sourceVersion = version;
            _sourceColumn = sourceColumn;
            _isNullable = isNullable;
        }
        #endregion

        #region IDataParameter Members

        private string _parameterName;
        #region public string ParameterName
        /// <summary>
        /// Get/Sets the ParameterName of the DataParameter
        /// </summary>
        /// <value></value>
        public string ParameterName
        {
            get { return _parameterName; }
            set { _parameterName = value; }
        }
        #endregion

        private object _value;
        #region public object Value
        /// <summary>
        /// Get/Sets the Value of the DataParameter
        /// </summary>
        /// <value></value>
        public object Value
        {
            get { return _value; }
            set { _value = value; }
        }
        #endregion

        private DbType _dbType;
        #region public DbType DbType
        /// <summary>
        /// Get/Sets the DbType of the DataParameter
        /// </summary>
        /// <value></value>
        public DbType DbType
        {
            get { return _dbType; }
            set { _dbType = value; }
        }
        #endregion

        private ParameterDirection _direction = ParameterDirection.Input;
        #region public ParameterDirection Direction
        /// <summary>
        /// Get/Sets the Direction of the DataParameter
        /// </summary>
        /// <value></value>
        public ParameterDirection Direction
        {
            get { return _direction; }
            set { _direction = value; }
        }
        #endregion

        private DataRowVersion _sourceVersion = DataRowVersion.Current;
        #region public DataRowVersion SourceVersion
        /// <summary>
        /// Get/Sets the SourceVersion of the DataParameter
        /// </summary>
        /// <value></value>
        public DataRowVersion SourceVersion
        {
            get { return _sourceVersion; }
            set { _sourceVersion = value; }
        }
        #endregion

        private string _sourceColumn;
        #region public string SourceColumn
        /// <summary>
        /// Get/Sets the SourceColumn of the DataParameter
        /// </summary>
        /// <value></value>
        public string SourceColumn
        {
            get { return _sourceColumn; }
            set { _sourceColumn = value; }
        }
        #endregion

        private bool _isNullable;
        #region public bool IsNullable
        /// <summary>
        /// Get/Sets the IsNullable of the DataParameter
        /// </summary>
        /// <value></value>
        public bool IsNullable
        {
            get { return _isNullable; }
            set { _isNullable = value; }
        }
        #endregion
        #endregion

        #region public override string ToString()
        /// <summary>
        /// Returns a <see cref="string"/> that represents the current <see cref="ICeFramework.Common.DataLayer.DataParameter"/>.
        /// </summary>
        /// <returns>A <see cref="string"/> that represents the current <see cref="ICeFramework.Common.DataLayer.DataParameter"/>.</returns>
        public override string ToString()
        {
            return "name=" + _parameterName + " value=" + _value.ToString();
        }
        #endregion
    }
}
